<?php

declare (strict_types=1);


namespace app\api\controller;

use app\common\model\User as UserModel;
use app\common\tool\Result;
use think\exception\ValidateException;
use think\Response;

class User extends Base
{
    /**
     * 获取用户信息
     */
    public function index()
    {
        $result = [
            'id' => $this->user->id ?? '',
            'nickname' => $this->user->nickname ?? '',
            'code' => $this->user->code,
            'photo' => $this->user->photo,
            'mobile' => $this->user->mobile ?: '',
        ];
        return Result::success('获取成功', $result);
    }
    /**
     * 修改个人信息
     */
    public function miniAppletEdit()
    {
        try {
            $param = $this->request->post();
            return Result::fastReturn(UserModel::_miniAppletEdit($param, $this->user));
        } catch (\Exception $e) {
            return Result::fail($e->getMessage());
        }

    }


}
